package com.lk.lkappearance.service.impl;

import com.lk.lkappearance.common.AbstractBaseService;
import com.lk.lkappearance.mapper.MeterParameterMapper;
import com.lk.lkappearance.model.Meter;
import com.lk.lkappearance.model.MeterParameter;
import com.lk.lkappearance.service.MeterParameterService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

public class MeterParameterServiceImpl extends AbstractBaseService implements MeterParameterService {

    @Autowired
    private MeterParameterMapper meterParameterMapper;

    /**
     * @param meterParameter
     * @return
     */
    @Override
    public Map<String, Object> add(MeterParameter meterParameter) {
        try {
            meterParameterMapper.insertSelective(meterParameter);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    /**
     * @param meterParameter
     * @return
     */
    @Override
    public Map<String, Object> modify(MeterParameter meterParameter) {
        try {
            meterParameterMapper.updateByPrimaryKeySelective(meterParameter);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    /**
     * @param meterParameterId
     * @return
     */
    @Override
    public Map<String, Object> delete(String meterParameterId) {
        try {
            meterParameterMapper.deleteByPrimaryKey(meterParameterId);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> selectByPrimaryKey(String meterParameterId) {
        try {
            meterParameterMapper.selectByPrimaryKey(meterParameterId);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> getList(MeterParameter meterParameter) {
        try {
            meterParameterMapper.getList(meterParameter);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> insertListExcel(List<MeterParameter> meterParameterList) {
        try {
            for (MeterParameter meterParameter:meterParameterList) {
                meterParameterMapper.insertSelective(meterParameter);
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> exportExcel(MeterParameter meterParameter) {
        try {
            meterParameterMapper.getList(meterParameter);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }
}
